import { _decorator, Component, Node, tween, v3 } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('GameEndLoseAni')
export class GameEndLoseAni extends Component {
   //喇叭的节点
   @property({ type: [Node] })
   public nodes: Node[] = [];

   @property({ type: Node })
   public hg: Node = null;

    start() {
        //喇叭的动作
        let v3_pos = [];
        for (let i = 0; i < this.nodes.length; i++) {
            v3_pos.push(this.nodes[i].getPosition());
        }

        for (let i = 0; i < this.nodes.length; i++) {
            let node = this.nodes[i];
            if (i >= 2) {
                tween()
                    .target(node)
                    .hide()
                    .to(0, { position: v3(0, 0, 0) })
                    .show()
                    .to(0.5, { position: v3_pos[i] }, { easing: 'backIn' })
                    .start()
            } else {
                tween()
                    .target(node)
                    .hide()
                    .to(0, { position: v3(0, 0, 0) })
                    .show()
                    .to(0.5, { position: v3_pos[i] }, { easing: 'backIn' })
                    .repeat(999999)
                    .start()
            }
        }

        //皇冠
        tween()
            .target(this.hg)
            .hide()
            .to(0, { position: v3(0, 0, 0) })
            .show()
            .to(0.5, { position: v3(0, 112.941, 0) }, { easing: 'backIn' })
            .start()
    }

    update(deltaTime: number) {
        
    }
}


